package com.example.lib.extend


fun <T> MutableList<T>.getRandom(count: Int): MutableList<T> {
    if (count <= 0) return mutableListOf()
    if (isEmpty()) return mutableListOf()
    val result = mutableListOf<T>()
    var isBreak = true
    while (result.size != count && isBreak) {
        val random = (0 until size).random()
        if (!result.contains(this[random])) {
            result.add(this[random])
        }
        if (result.size == size) {
            isBreak = false
        }
    }
    return result
}

fun <T> MutableList<T>.copy(): MutableList<T> {
    return mutableListOf<T>().also {
        it.addAll(this)
    }
}